<template>
  <div v-if="!!data1 && !!data2" class="total-container">
    <div class="chart-title">{{ data1[0].lb }}</div>
    <div class="flex-container">
      <div class="item-box" v-for="item in data1" :key="item.name">
        <div class="title">{{ item.xm }}</div>
        <div class="value">
          <div class="num">
            <CountTo
              :startVal="0"
              :endVal="+item.sz"
              :duration="1200"
              separator=""
            ></CountTo>
          </div>
          <div class="unit">{{ item.unit }}</div>
        </div>
      </div>
    </div>
    <div class="chart-title">{{ data2[0].lb }}</div>
    <div class="flex-container">
      <div class="item-box" v-for="item in data2" :key="item.name">
        <div class="title">{{ item.xm }}</div>
        <div class="value">
          <div class="num">
            <CountTo
              :startVal="0"
              :endVal="+item.sz"
              :duration="1200"
              separator=""
            ></CountTo>
          </div>
          <div class="unit">{{ item.unit }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getLbData } from '@/api/cultureTuorism.js'
import CountTo from 'vue-count-to'
export default {
  data() {
    return {
      data1: null,
      data2: null
    }
  },
  components: {
    CountTo
  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      const [res1, res2] = await Promise.all([
        getLbData('全市文物概况'),
        getLbData('全市博物馆概况')
      ])
      this.data1 = res1.result
      this.data2 = res2.result
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  .chart-title {
    width: 420px;
    height: 31px;
    margin-bottom: 7px;
    background: url('../../img/right-row1-icon1.png') no-repeat center center;
    background-size: 100% 100%;
    display: flex;
    justify-content: start;
    align-items: center;
    padding-left: 15px;
    font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
    line-height: 16px;
    text-align: left;
    font-style: normal;
    text-transform: none;
  }
  .flex-container {
    height: 76px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .item-box {
      height: 76px;
      width: 199px;
      background: url('../../img/left-row2-icon1.png') no-repeat center center;
      background-size: 100% 100%;
      text-align: center;
      padding-top: 15px;
      .title {
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #ffffff;
        line-height: 16px;
        text-align: center;
        font-style: normal;
        text-transform: none;
      }
      .value {
        display: flex;
        justify-content: center;
        align-items: baseline;
        margin-top: 10px;
      }
      .num {
        font-family: YouSheBiaoTiHei;
        font-size: 24px;
        color: #16fdf5;
        line-height: 24px;
        text-align: center;
        font-style: normal;
        text-transform: none;
      }
      .unit {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #fefefe;
        line-height: 14px;
        text-align: center;
        font-style: normal;
        text-transform: none;
        margin-left: 4px;
      }
    }
  }
}
</style>
